package com.by.config;

import com.by.interceptor.AuthInterceptor;
import com.by.interceptor.TokenValidIntercepor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    //拦截器注册
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new AuthInterceptor())//new TokenValidIntercepor()
        registry.addInterceptor(new TokenValidIntercepor())
                .addPathPatterns("/api/**")  // 拦截以/api开头的所有请求
        ;
    }
}

